﻿@using MvcApplication2.ViewModels
@model  EmployeeListViewModel
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
   
}

@section ContentBody{  
    @{
        Html.RenderAction("GetAddNewLink");
        }
    <div class="table-responsive">
    <table class="table  table-hover" >
        <thead><tr><th>Employee Info</th></tr></thead>
        <tbody>
        @foreach(EmployeeViewModel em in Model.list)
        {
        <tr>
            <td>@em.EmpID</td>
            <td>
        @em.EmployeeName    
            </td>
            
          <td>
             EmployeeSalary:@em.Salary
      </td>
       <td>
           <a  onclick="deleteem('@em.EmpID')"   href="#"  class="btn btn-default active">辞退</a>
       </td>
   </tr>
         
        }
  </tbody>
   </table>
        </div>
    <div id="dialog" title="确认" >
  <p>是否辞退</p>
</div>
    <script type="text/javascript">
       $.ready( $("#dialog").hide())
        function AddNew()
        {
            $.get("/Employee/AddNew").then(
                function (r) {
                    $("<div id='main'></div>").html(r).dialog(
                        {
                            width: 'auto', height: 'auto', modal: true, title: "创建新员工",
                            close: function () {
                                $('#main').remove();
                            }
                        });
                }
                );
        }
        function BulkUpload()
        {
            $.get("/BulkUpload/UploadEm").then(
                function (r) {
                    $("<div id='content'></div>").html(r).dialog({
                        width: 'auto', height: 'auto', modal: true, title: "上传新员工",
                        close: function () {
                            $('#content').remove();
                        }
                    });
                }
                );
        }
        function deleteem(r) {

            //$.get("/Employee/DeleteEmployeess", {data:r}).then(
            //  function (s) {
            //      $("<div id='de'></div>").html(s).dialog(
            //          {
            //              width: 'auto', height: 'auto', modal: true, title: "创建新员工",
            //              close: function () {
            //                  $('#de').remove();
            //              }
            //          });
            //  }
            //  );



            $("#dialog").dialog({
                width: 'auto', height: 'auto', modal: true, title: "提示",
                buttons: {
                    "确认": function () {
                        $.post("/Employee/DeleteEmployee", { data: r }, function () {
                            $("#dialog").remove();
                            window.location.reload();
                        });
                    },
                    "取消": function () {
                        $(this).dialog("close");
                    }
                }
            })
        
        }


    </script>
    }

